package com.lagou.studentsystem.servlet;

import com.lagou.studentsystem.dao.ClassesDao;
import com.lagou.studentsystem.dao.Impl.ClassesDaoImpl;
import com.lagou.studentsystem.model.Classes;


import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "FindClassesAllServlet",urlPatterns = "/findClassesAll")
public class FindClassesAllServlet extends HttpServlet {

    private ClassesDao classesDao = new ClassesDaoImpl();

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        List<Classes> classesAll = classesDao.getClassesAll();
        System.out.println(classesAll);
        if (null != classesAll) {
                    request.getSession().setAttribute("classesList", classesAll);
                    response.sendRedirect("class.jsp");
        }else {

        }
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
